package com.kedsoft.andaily.api;

import com.kedsoft.andaily.service.impl.JpushService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by Administrator on 2019/5/3.
 */
@Api("极光推送测试")
@RestController
@RequestMapping("api/push")
public class JPushTestController {
    @Autowired
    JpushService jpushService;

    @RequestMapping(value = "test", method = RequestMethod.GET)
    @ApiOperation(value = "测试")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType = "query", name = "title", dataType = "String",defaultValue = "通知头", required = true, value = "通知头"),
            @ApiImplicitParam(paramType = "query", name = "msg", dataType = "String", defaultValue = "内容", required = false, value = "通知类容"),
            @ApiImplicitParam(paramType = "query", name = "tag", dataType = "String", defaultValue = "13621590030", required = false, value = "通知人"),
    })
    public String test(@RequestParam String title, @RequestParam String msg, @RequestParam String tag){
        Map<String, String> extrasMap = new HashMap<String, String>();
        //此Map必须创建和实例化，但可以不添加内容
        //extrasMap.put("额外附加传递内容","App可以解析到，没有值仅实例化即可");

        //方式一：服务端控制推送内容方式
        jpushService.sendPush(title, msg, extrasMap);
        return "success";

    }
}
